package type;

import java.util.HashMap;

public class User {
	private double meanRating;
	private int userID;
	private int age;
	private Sex sex;
	private String occupation;
	private String zipCode;
	private HashMap<Movie,Rating> ratingList;
	
	public User(int userID, int age, Sex sex, String occupation, String zipCode){
		this.setUserID(userID);
		this.setAge(age);
		this.setSex(sex);
		this.setOccupation(occupation);
		this.setZipCode(zipCode);
		ratingList = new HashMap<Movie,Rating>();
	}
	
	@Override
	public String toString() {
		return "userID:" + userID + " age:" + age + " sex:" + sex.toString() + " occupation:" + occupation + " zipCode:" + zipCode;
	}

	public int getUserID() {
		return userID;
	}

	public void setUserID(int userID) {
		this.userID = userID;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public Sex getSex() {
		return sex;
	}

	public void setSex(Sex sex) {
		this.sex = sex;
	}

	public String getOccupation() {
		return occupation;
	}

	public void setOccupation(String occupation) {
		this.occupation = occupation;
	}

	public String getZipCode() {
		return zipCode;
	}

	public void setZipCode(String zipCode) {
		this.zipCode = zipCode;
	}

	public HashMap<Movie,Rating> getRatingList() {
		return ratingList;
	}

	public void addRating(Rating rating) {
		this.ratingList.put(rating.getMovie(), rating);
	}
	
	public void clearRating(){
		this.ratingList.clear();
	}
	
	public void computeMeanRating()
	{
		meanRating = 0.0;
		if(ratingList.size() > 0)
		{
			for(Rating r : this.ratingList.values())
			{
				meanRating += r.getRating();
			}
			meanRating /= ratingList.size();
		}
	}
	
	public double getMeanRating()
	{
		return meanRating;
	}
}
